<template>
	<div class="list-page">
		<tool-bar nav="" title="短信消息">
			<el-button @click="add_click()">添加</el-button>
		</tool-bar>
		<my-list
			ref="list"
			url="/log/mobile-code-log/list"
			@param="preload"
			@loaded="procData"
			:page-size="10"
			:store="true"
		>
			<el-table-column type="index" align="center" width="50"></el-table-column>
			<!--<template v-slot="scope"></template>-->
			<el-table-column align="center" label="模块" width="100" prop="module_res"></el-table-column>
			<el-table-column align="center" label="手机号" width="120" prop="mobile"></el-table-column>
			<el-table-column align="center" label="参数" width="180" prop="param"></el-table-column>
			<el-table-column align="center" label="结果">
				<template v-slot="scope">
					<div v-if="scope.row.result">{{ scope.row.result.code }}: {{ scope.row.result.description }}</div>
				</template>
			</el-table-column>
			<el-table-column align="center" label="错误" prop="errorMessage"></el-table-column>
			<el-table-column align="center" label="创建时间" width="160" prop="createAt"></el-table-column>


			<template #query="scope">
				<kv label="模块">
					<el-input v-model="scope.query.module"></el-input>
				</kv>
				<kv label="手机号">
					<el-input v-model="scope.query.mobile"></el-input>
				</kv>

				<kv label="结果">
					<el-input v-model="scope.query.result"></el-input>
				</kv>
				<kv label="错误消息">
					<el-input v-model="scope.query.errorMessage"></el-input>
				</kv>
			</template>
		</my-list>
	</div>
</template>
<style scoped>
</style>
<script>
/**
 * Created by CodeGenerator at 2022-02-22 15:33:17
 */
export default {
	components: {},
	data() {
		return {
			MobileCodeModuleEnum: jv.enum.MobileCodeModuleEnum.getData(),
		};
	},
	methods: {
		//处理请求参数
		preload(param) {
			//添加查询参数，修改分页参数等。
			//param.type = this.$route.params.type
		},
		//处理列表的数据
		procData(res) {
			res.data.data.forEach(it => {
				//如果是组合实体，设置 it.id=...
				jv.enum.MobileCodeModuleEnum.fillRes(it, "module");
			});
		},
		//查询
		loadData(pageNumber) {
			this.$refs.list.loadData(pageNumber);
		},
		add_click() {
			this.$router.push("/log/mobile-code-log/add")
		},
		edit_click(row) {
			//记录上次点击行
			var rowId = row.id;
			this.$refs.list.setLastRow(row);
			this.$router.push("/log/mobile-code-log/edit/" + rowId)
		},
		async delete_click(row) {
			var rowId = row.id, rowName = row.name;
			await jv.confirm('确认删除 ' + rowName + ' 吗？');

			var res = await this.$http.post("/log/mobile-code-log/delete/" + rowId)
			this.loadData();
		}
	}
}
</script>